import { GETDARK, SETDARK } from "@/utils/local"
import { defineStore } from "pinia"
import { reactive, ref } from "vue"
export const useSettingStore  = defineStore('setting', 
    () => {
     /***
     * @刷新
     */
    const flush = ref(false)
    const changeFlush = () => {
        flush.value = !flush.value
      }
     /***
     * @侧边栏的折叠
     */
    const flag = ref(false)
    const changeFlag = () => {
      flag.value = !flag.value
    }

      /**
     * @主题相关
     */
      const dark = ref(true|| GETDARK())
      const changeDark = () => {
        dark.value = !dark.value
        SETDARK(dark.value)
      }

       /**
     * @页面设置
     */
       const page_setting = reactive({
        isShow_Tagview: true,
        isShow_Logo: true,
        isShow_Bread: true,
      })
      /**
       * @语言
       */
      const language = ref(localStorage.getItem('language') || 'zh')
      const changeLanguage = (value:string) => {
        language.value = value
      }
      return {
        flag,
        dark,
        flush,
        page_setting,
        language,
        changeFlag,
        changeFlush,
        changeDark,
        changeLanguage
      }
    },
    // 持久化存储pinia的插件
    {
        persist: {
          key: "page_setting",
          paths: ["page_setting"],
        },
   }
)